from core.support import set_cutscene
from core.item import Item
from core.action import Action

class test2(Item):
    def __init__(self):
        Item.__init__(self, "test2")    # do basic initialization for every item
        self.test_taken = False
        self.test_submitted = False
        
        # build list of actions
        self.add_action(TakeTest)
        self.add_action(SubmitTest)
    
    def get_description(self):
            return "Final exam"


# define actions for this item

class TakeTest(Action):
    def __init__(self):
        Action.__init__(self, "take_test")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Take test"
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "post"
    
    # enabled only if lamp is you havent taken the test.
    def is_enabled(self):
        if self.item.test_taken:
            return False
        else:
            return True
    
    # turn lamp on and add cutscene
    def do_action(self,game,room,request):
        self.item.test_taken = True
        set_cutscene("These don't get easier! Good thing nobody fails out of business school.")
        return


class SubmitTest(Action):
    def __init__(self):
        Action.__init__(self, 'submit_test')
        
    def get_description(self):
        return 'Hand-in test'
    
    def get_method(self):
        return 'post'

    # enabled only if lamp is you havent taken the test.
    def is_enabled(self):
        if self.item.test_submitted:
            return False
        else:
            return self.item.test_taken

    def do_action(self,game,room,request):
        self.item.test_submitted = True
        set_cutscene("You turn in the test.")
